﻿using System;
using System.Xml.Serialization;

namespace uTILLIty.Rave.Contract.Job
{
  /// <summary>
  /// An NVelocity array defined in a <see cref="Job"/>
  /// </summary>
  public class ListMergeVariable : MergeVariable
  {
    /// <summary>
    /// Creats an empty instance
    /// </summary>
    public ListMergeVariable()
    {
    }

    /// <summary>
    /// Creates a filled-out instance
    /// </summary>
    /// <param name="key"></param>
    /// <param name="values"></param>
    public ListMergeVariable(string key, string[] values)
      : base(key, null)
    {
      Values = values;
    }

    /// <summary>
    /// Not supported! Use <see cref="Values"/> instead
    /// </summary>
    /// <exception cref="NotSupportedException">raised, if the setter is invoked</exception>
    [XmlIgnore]
    public override object Value
    {
      get { return Values; }
      set { if (value != null) throw new NotSupportedException(); }
    }

    /// <summary>
    /// The values-array
    /// </summary>
    [XmlArrayItem("Value")]
    public string[] Values { get; set; }
  }
}